Importance of Data Structure
Encapsulation
Version A:
z.Re = x.Re + y.Re
z.Im = x.Im + y.Im
Version B:
z[0] = x[0] + y[0]
z[1] = x[1] + y[1]
For example the addition of two complex numbers
requires you to perform an addition for each part.
Consequently, you must access the value of each part
which is different for each version. By providing an
operation “add'' you can encapsulate these details from
its actual use. In an application context you simply “add
two complex numbers'' regardless of how this
functionality is actually achieved.